package com.vision.core.cl;

import com.google.gwt.user.client.rpc.ServiceDefTarget;

/**
 * @author Mark
 *
 */
public class Services {
	
	@SuppressWarnings("unchecked")
	public static <T> T create(Object serviceAsync) {
		ServiceDefTarget endpoint = (ServiceDefTarget) serviceAsync;
		String entryPoint = endpoint.getServiceEntryPoint();
		int index = entryPoint.lastIndexOf("/");
		String serviceName = entryPoint.substring(index + 1);
		// Prepend "rpc" before the service's name
		endpoint.setServiceEntryPoint(entryPoint.substring(0, index + 1) + "rpc/" + serviceName);
		return (T) serviceAsync;
	}

}
